/*
package tests;

import static org.junit.Assert.*;

import java.awt.geom.Point2D;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import ownserver.Ship;

import com.sun.sgs.auth.Identity;
import com.sun.sgs.kernel.TransactionScheduler;
import com.sun.sgs.service.DataService;
import com.sun.sgs.test.util.SgsTestNode;
import com.sun.sgs.test.util.TestAbstractKernelRunnable;

public class ShipTest {

	private static SgsTestNode serverNode;
	
    private static TransactionScheduler txnScheduler;
    private static Identity taskOwner;
    private static DataService dataService;
    
    private static final String NAME = "ShipTest";
    
    private static double errorLimit = 1E-12;
	
    private static final Logger logger =
            Logger.getLogger(ShipTest.class.getName());
    
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		serverNode = new SgsTestNode(NAME, null, null);
        
        
        txnScheduler = serverNode.getSystemRegistry().
                getComponent(TransactionScheduler.class);
        taskOwner = serverNode.getProxy().getCurrentOwner();
        dataService = serverNode.getDataService();
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
		serverNode.shutdown(true);
	}

	@Test
	public void testConstructor() throws Exception {
		txnScheduler.runTask(
				new TestAbstractKernelRunnable() {
				public void run() throws Exception {
					Ship s = getTestShip(0, 20, 0);
					Ship b = new Ship(0, 0, 0, 0, null, 0);
					
				}
				}, taskOwner);
	}

	@Test
	public void testGetPublicChannel() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testGetOwner() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testAttachTurret() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testGetTurret() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testGetNumTurrets() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testSetMoveTarget() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testSetAttackTarget() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testSetHeading() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testGetNextIndex() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testGetPrevIndex() {
		fail("Not yet implemented"); // TODO
	}

	public void closeEnough(double a, double b)
	{
		if (Math.abs(a-b) < errorLimit == false)
		{
			logger.log(Level.INFO, "Not close enough: {0} vs {1}",
		            new Object[] {a,b});
		}
		assertTrue(Math.abs(a-b) < errorLimit);
	}
	
	// tests if two given vectors are orthogonal
	// (i.e. their inner product is 0)
	public void orthogonal(Point2D.Double a, Point2D.Double b)
	{
		closeEnough(a.x * b.x + a.y * b.y, 0);
	}
	
	public Point2D.Double [] vectorsFromRect(Point2D.Double[] corners)
	{
		Point2D.Double [] result = new Point2D.Double [4];
		result[0] = new Point2D.Double(corners[1].x - corners[0].x, corners[1].y - corners[0].y);
		result[1] = new Point2D.Double(corners[2].x - corners[1].x, corners[2].y - corners[1].y);
		result[2] = new Point2D.Double(corners[3].x - corners[2].x, corners[3].y - corners[2].y);
		result[3] = new Point2D.Double(corners[0].x - corners[3].x, corners[0].y - corners[3].y);
		return result;
	}
	
	@Test
	public void testGetRect() throws Exception {
		txnScheduler.runTask(
				new TestAbstractKernelRunnable() {
				public void run() throws Exception {
					// ship with a straight up heading, angle 90
					double x = 30;
					double y = 25;
					Ship a = getTestShip(x, y, 90);
					double width = Ship.getWidth() / 2;
					double length = Ship.getLength() / 2;
					
					Point2D.Double [] corners = a.getRect();
					// the rectangle forms from 4 vectors that go from 0 -> 1, 1 -> 2, 2 -> 3, 3 -> 0
					Point2D.Double [] v = vectorsFromRect(corners);
					
					orthogonal(v[0], v[1]);
					orthogonal(v[1], v[2]);
					orthogonal(v[2], v[3]);
					orthogonal(v[3], v[0]);
					
					// check the vertices are correct length
					double widthSquared = Ship.getWidth() * Ship.getWidth();
					double lengthSquared = Ship.getLength() * Ship.getLength();
					closeEnough(v[0].x * v[0].x + v[0].y * v[0].y, widthSquared);
					closeEnough(v[1].x * v[1].x + v[1].y * v[1].y, lengthSquared);
					closeEnough(v[2].x * v[2].x + v[2].y * v[2].y, widthSquared);
					closeEnough(v[3].x * v[3].x + v[3].y * v[3].y, lengthSquared);
					
					
					closeEnough(corners[0].x, x - width);
					closeEnough(corners[0].y, y + length);
					
					closeEnough(corners[1].x, x + width);
					closeEnough(corners[1].y, y + length);
					
					closeEnough(corners[2].x, x + width);
					closeEnough(corners[2].y, y - length);
					
					closeEnough(corners[3].x, x - width);
					closeEnough(corners[3].y, y - length);
					
					// ship heading right, 0 heading
					a = getTestShip(x, y, 0);
					corners = a.getRect();
					closeEnough(corners[0].x, x + length);
					closeEnough(corners[0].y, y + width);
					
					closeEnough(corners[1].x, x + length);
					closeEnough(corners[1].y, y - width);
					
					closeEnough(corners[2].x, x - length);
					closeEnough(corners[2].y, y - width);
					
					closeEnough(corners[3].x, x - length);
					closeEnough(corners[3].y, y + width);
					
					a = getTestShip(x,y,30);
					corners = a.getRect();
					
					// ship with 60 heading
					a = getTestShip(x, y, 60);
					
					corners = a.getRect();
					v = vectorsFromRect(corners);
					
					orthogonal(v[0], v[1]);
					orthogonal(v[1], v[2]);
					orthogonal(v[2], v[3]);
					orthogonal(v[3], v[0]);
					
					closeEnough(v[0].x * v[0].x + v[0].y * v[0].y, widthSquared);
					closeEnough(v[1].x * v[1].x + v[1].y * v[1].y, lengthSquared);
					closeEnough(v[2].x * v[2].x + v[2].y * v[2].y, widthSquared);
					closeEnough(v[3].x * v[3].x + v[3].y * v[3].y, lengthSquared);
					
					a = getTestShip(x, y, 130);
					
					corners = a.getRect();
					v = vectorsFromRect(corners);
					
					orthogonal(v[0], v[1]);
					orthogonal(v[1], v[2]);
					orthogonal(v[2], v[3]);
					orthogonal(v[3], v[0]);
					
					closeEnough(v[0].x * v[0].x + v[0].y * v[0].y, widthSquared);
					closeEnough(v[1].x * v[1].x + v[1].y * v[1].y, lengthSquared);
					closeEnough(v[2].x * v[2].x + v[2].y * v[2].y, widthSquared);
					closeEnough(v[3].x * v[3].x + v[3].y * v[3].y, lengthSquared);
					
					a = getTestShip(x, y, 280);
					
					corners = a.getRect();
					v = vectorsFromRect(corners);
					
					orthogonal(v[0], v[1]);
					orthogonal(v[1], v[2]);
					orthogonal(v[2], v[3]);
					orthogonal(v[3], v[0]);
					
					closeEnough(v[0].x * v[0].x + v[0].y * v[0].y, widthSquared);
					closeEnough(v[1].x * v[1].x + v[1].y * v[1].y, lengthSquared);
					closeEnough(v[2].x * v[2].x + v[2].y * v[2].y, widthSquared);
					closeEnough(v[3].x * v[3].x + v[3].y * v[3].y, lengthSquared);
					
					a = getTestShip(0, 0, 213);
					
					corners = a.getRect();
					v = vectorsFromRect(corners);
					
					orthogonal(v[0], v[1]);
					orthogonal(v[1], v[2]);
					orthogonal(v[2], v[3]);
					orthogonal(v[3], v[0]);
					
					closeEnough(v[0].x * v[0].x + v[0].y * v[0].y, widthSquared);
					closeEnough(v[1].x * v[1].x + v[1].y * v[1].y, lengthSquared);
					closeEnough(v[2].x * v[2].x + v[2].y * v[2].y, widthSquared);
					closeEnough(v[3].x * v[3].x + v[3].y * v[3].y, lengthSquared);
					
					// rectangle going over the axes
					a = getTestShip(5, -1, 2);
					
					corners = a.getRect();
					v = vectorsFromRect(corners);
					
					orthogonal(v[0], v[1]);
					orthogonal(v[1], v[2]);
					orthogonal(v[2], v[3]);
					orthogonal(v[3], v[0]);
					
					closeEnough(v[0].x * v[0].x + v[0].y * v[0].y, widthSquared);
					closeEnough(v[1].x * v[1].x + v[1].y * v[1].y, lengthSquared);
					closeEnough(v[2].x * v[2].x + v[2].y * v[2].y, widthSquared);
					closeEnough(v[3].x * v[3].x + v[3].y * v[3].y, lengthSquared);
				}
				}, taskOwner);
	}

	@Test
	public void testGetBoxX() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testGetBoxY() {
		fail("Not yet implemented"); // TODO
	}

	@Test
	public void testGetHeading() {
		fail("Not yet implemented"); // TODO
	}

	// Returns a ship that is 20 units wide and 4 units long, with the center point being at the center of the rectangle.
	
	public static Ship getTestShip(double x, double y, double heading)
	{
		
		Ship s = new Ship(0,0,x,y,null,0);
		
		
		s.setHeading(heading);
		return s;
		
	}
	
}
*/